跳到主要内容

InsertParagraph

Inserts a paragraph at the specified position.

Syntax

expression.InsertParagraph(paragraph, sPosition, beRNewPara);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
paragraphRequiredstringApiParagraph
sPositionRequiredstringThe position where the text or paragraph will be inserted ("before" or "after" the paragraph specified).
beRNewParaRequiredbooleanDefines if this method returns a new paragraph (true) or the current paragraph (false).

Returns

ApiParagraph | null

Example

This example inserts a paragraph at the specified position.

let doc = Api.GetDocument();
let paragraph1 = doc.GetElement(0);
paragraph1.AddText("This is just a sample text.");
let paragraph2 = Api.CreateParagraph();
paragraph2.AddText("This paragraph was inserted here.");
paragraph1.InsertParagraph(paragraph2, "after", true);